package org.liveboardgames.agricola.control.delegates.action.processor
{
	import org.liveboardgames.agricola.model.enums.ActionOutputEnum;
	import org.liveboardgames.agricola.model.enums.ResourceTypeEnum;
	import org.liveboardgames.agricola.vo.action.Action;
	import org.liveboardgames.common.utils.Enums;

	public class ActionProcessorFactory
	{

		public static function getProcessor(outputType:String, outputQuantity:int, action:Action):ActionProcessor
		{
			var processor:ActionProcessor = null;

			var resourceType:String = Enums.convertActionOutputToResource(outputType);
			if (resourceType != null && ResourceTypeEnum.ANIMALS.contains(resourceType))
			{
				processor = new AnimalActionProcessor(action, resourceType, outputQuantity);
			}
			else if (outputType == ActionOutputEnum.CHOICE_RESOURCE)
			{
				processor = new ChooseBuildingMaterialActionProcessor(action);
			}
			else if (outputType == ActionOutputEnum.PLOUGH)
			{
				processor = new PloughActionProcessor(action);
			}
			else if (outputType == ActionOutputEnum.WOODEN_ROOM || outputType == ActionOutputEnum.CLAY_ROOM || outputType ==
				ActionOutputEnum.STONE_ROOM)
			{
				processor = new RoomActionProcessor(action);
			}
			else if (outputType == ActionOutputEnum.STABLE)
			{
				processor = new StableActionProcessor(action);
			}
			else if (outputType == ActionOutputEnum.MAJOR_IMPROVEMENT)
			{
				processor = new BuildMajorImprovementActionProcessor(action);
			}
			else if (outputType == ActionOutputEnum.BAKE)
			{
				processor = new BakeActionProcessor(action);
			}
			else if (outputType == ActionOutputEnum.SOW)
			{
				processor = new SowActionProcessor(action);
			}
			else if (outputType == ActionOutputEnum.TAKE_ANIMAL)
			{
				processor = new AnimalActionProcessor(action);
			}
			else if (outputType == ActionOutputEnum.PASTURE)
			{
				processor = new FencesActionProcessor(action);
			}
			else
			{
				throw new Error("No processor for action type " + outputType);
			}

			return processor;
		}
	}
}